#!/bin/sh
# +++ 变量声明 Start+++
export g_libId="sdl2-2.0.10-ugc"
# 源码-库目录
export g_sourceLibDir=${g_inputRootDir}/${g_libId}
# 脚本-库目录
g_scriptLibDir=${g_scriptArchDir}/${g_libId}
# Build-库目录
export g_buildLibDir=${g_buildArchDir}/${g_libId}
if [[ ! -e ${g_buildLibDir} ]]; then
    mkdir -p ${g_buildLibDir}
fi

# Output-库目录
export g_outputLibDir=${g_outputArchDir}/${g_libId}
if [[ ! -e ${g_outputLibDir} ]]; then
    mkdir -p ${g_outputLibDir}
fi


# 定义CFLAGS
export CFLAGS=""
CFLAGS+=" -Wno-unused-local-typedef"
CFLAGS+=" -Wno-unused-function"
CFLAGS+=" -fPIC"
CFLAGS+=" -fobjc-arc"
CFLAGS+=" -fembed-bitcode=off"
CFLAGS+=" -arch $g_arch"
if [[ $g_compileMode == $COMPILE_MODE_DEBUG ]]; then
    CFLAGS+=" -DNDEBUG -g -O0 -pipe"
fi

export CC="$g_cc"

# 需要手动将配置文件放到build目录,make会根据该文件配置.
function afterConfigure() {
    echo "after configure";
    cp $g_inputRootDir/$g_libId/include/SDL_config_iphoneos.h $g_buildArchDir/$g_libId/include/SDL_config.h
}

# 定义configure flag
export g_flag=""
g_flag+=" --disable-shared"
g_flag+=" --enable-static=no"
g_flag+=" --host=$g_host"
g_flag+=" --prefix=${g_outputLibDir}"

function doFinish() {
    unset CFLAGS   #需要关闭掉,否则会影响后后续ffmpeg的编译,arc模式,里面有些文件不是arc的.
    unset CC
    unset g_flag
    unset afterConfigure
    unset doFinish
}